from django.db import models
import django.utils.timezone as timezone


class Admin(models.Model):
    """用户信息表"""

    name = models.CharField(verbose_name="姓名", max_length=128, unique=True)
    username = models.CharField(verbose_name="用户名", max_length=128, unique=True)
    del_flag = models.IntegerField(verbose_name="是否删除", default=0)
    password = models.CharField(verbose_name="密码", max_length=256)
    create_time = models.DateTimeField(verbose_name="创建时间", default=timezone.now)
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")
    position_choices = (
        (1, "管理员"),
        (2, "用户")
    )
    position = models.SmallIntegerField(verbose_name="职位", choices=position_choices, default=2)

    class Meta:
        db_table = 'user_info'

    def __str__(self):
        return self.username, self.name, self.create_time, self.update_time, self.position


class JD_Account(models.Model):
    """京东账号表"""
    account = models.CharField(verbose_name="JD账号",max_length=128, unique=True)
    user_id = models.IntegerField(verbose_name="用户ID",unique=True)
    del_flag = models.IntegerField(verbose_name="是否删除",default=0)
    password = models.CharField(verbose_name="密码",max_length=256)
    cookie = models.CharField(verbose_name="cookie",max_length=256)
    create_time = models.DateTimeField(verbose_name="创建时间", default=timezone.now)
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'jd_account'


class E_Card(models.Model):
    """E卡信息表"""
    account_id = models.IntegerField(unique=True)
    card_id = models.IntegerField(unique=True)
    money_value = models.IntegerField(unique=True)
    card_password = models.CharField(max_length=256)
    status = models.IntegerField(default=0)
    create_time = models.DateTimeField(verbose_name="创建时间", default=timezone.now)
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'e_card'


class PrettyNum:
    objects = None
